package com.ydkfjs.utils;

import com.ydkfjs.constants.HttpStatus;
import com.ydkfjs.exception.BusinessException;

public class HBAssert {

    private static final int DEFAULT_ERROR_CODE = HttpStatus.ERROR;

    public HBAssert() {

    }

    public static void isTrue(boolean expression, String message) {
        isTrue(expression, DEFAULT_ERROR_CODE, message);
    }


    public static void isFalse(boolean expression, String message) {
        isFalse(expression, DEFAULT_ERROR_CODE, message);
    }

    public static void isTrue(boolean expression, int code, String message) {
        if (!expression) {
            throw new BusinessException(code, message);
        }
    }

    public static void isFalse(boolean expression, int code, String message) {
        if (expression) {
            throw new BusinessException(code, message);
        }
    }

    public static void isNull(Object object, String message) {
        isNull(object, DEFAULT_ERROR_CODE, message);
    }

    public static void isNull(Object object, int code, String message) {
        if (object != null) {
            throw new BusinessException(code, message);
        }
    }

    public static void notNull(Object object, String message) {
        notNull(object, DEFAULT_ERROR_CODE, message);
    }

    public static void notNull(Object object, int code, String message) {
        if (object == null) {
            throw new BusinessException(code, message);
        }
    }


}